package bomberman;

import java.awt.CardLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JPanel;

import bomberman.swing.BomJFrame;
import bomberman.swing.BomJPanel;
import bomberman.util.Constants;

public class MainGame {

	public static BomJFrame jFrame = new BomJFrame();
	public static JPanel jPanelMain = new JPanel();
	public static BomJPanel jPanelIndex = new BomJPanel();
	
	public static CardLayout card = new CardLayout(0, 0);
	
	/**
	 * 游戏主入口
	 */
	public static void main(String[] args) {
		MainGame mg = new MainGame();
		mg.initGame();
	}

	/**
	 * 初始化界面
	 */
	public void initGame() {
		jFrame = new BomJFrame();

		jPanelMain.setLayout(card);
		jPanelIndex.setFocusable(true);
		jPanelMain.add(Constants.PANEL_INDEX, jPanelIndex);
		jFrame.setContentPane(jPanelMain);

		jFrame.setTitle(Constants.GAME_NAME);
		jFrame.setSize(Constants.WINDOW_WIDTH, Constants.WINDOW_HEIGHT);
		jFrame.setLocation(Constants.WINDOW_LOCATION_X, Constants.WINDOW_LOCATION_Y);
		jFrame.setResizable(true);
		jFrame.setVisible(true);
		jFrame.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				// 关闭线程池
//				MyRunableThreadPool.getExecutorService().shutdown();
				System.exit(0);
			}
		});
	}
	
}
